const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    userInfo:{
      type:Object,
      value:{}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    isShow:false,
    isfocus:true,
    number:''
  },

  /**
   * 组件的方法列表
   */
  methods: {
    bindNumberInput(e){
      this.setData({
        number:e.detail.value
      })
    },
    allPrice(){
      let userInfo = app.functions.getLocalStorage('user');
      this.setData({
        number:userInfo.credit2
      })

    },

    isopen(){
      this.setData({
        isShow: true
      })
    },
    cancel(){
      this.setData({
        isShow: false,
        number:''
      })
    },
    confirm(){
      let that=this;
      let userInfo = app.functions.getLocalStorage('user');
      if(!that.data.number){
        app.functions.showToast("金额不能为空！");
        return ;
      }
      if (that.data.number < 1) {
        app.functions.showToast("金额请输入超过1元！");
        return;
      }
      if(that.data.number > userInfo.credit2){
        app.functions.showToast("金额输入过大！");
        return ;
      }
      
      let params={
        memberId:userInfo.id,
        money:that.data.number
      };
      app.api.BalancePick(params,(response)=>{
        if(response.code!=0){
          app.functions.showToast("提现申请失败，请联系客服！");
          return ;
        }
        app.functions.showToast("提现申请成功");
        app.cache['pages/user/user'].GetUserInfo();
        that.cancel();
      },(error)=>{
        app.functions.showToast("提现申请失败");
        that.cancel();
      })
    },
    // 提现记录
    toPickRecord(){
      wx.navigateTo({ 
        url: '/pages_user/pick_record/pick_record' 
      });
    }
  }
})
